package com.icxcc.common.util;

import lombok.Data;

import java.io.Serializable;

@Data
public class R<T> implements Serializable {
    Integer code;
    String msg;
    T data;

    public R(){

    }

    public R(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public R(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static R OK() {
        return R.OK("请求成功!");
    }
    public static R OK(Object data) {
        return R.OK("请求成功!",data);
    }
    public static R OK(String msg) {
        return R.OK(msg, null);
    }
    public static R OK(String msg, Object data) {
        return R.OK(0,msg,data);
    }
    public static R OK(Integer code, String msg, Object data) {
        return new R(code,msg,data);
    }

    public static R failed(Integer code, String msg){
        return new R(code, msg);
    }
}
